package phapp.springSecurity;

import java.io.*;
import javax.servlet.*;

public class CharsetFilter implements Filter
{

   private String encoding;

   public void destroy()
   {
   }
 
   public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException
   {
      //System.out.println("CharsetFilter::doFilter - setCharacterEncoding[" + encoding + "]");
      
      //设置字符集
      servletRequest.setCharacterEncoding(this.encoding);
      filterChain.doFilter(servletRequest, servletResponse);
   }
 
   public void init(FilterConfig filterConfig) throws ServletException
   {
      this.encoding = filterConfig.getInitParameter("encoding");
   }

}
